package day06;

import java.util.Arrays;

public class MaxDemo {

    public static void main(String[] args) {
        int[] arr = new int[10];
        for (int i = 0; i < arr.length; i++) {  //遍历arr数组
            arr[i] = (int) (Math.random() * 100); //给每个元素赋值为0到99.9999
            System.out.println(arr[i]);  //输出每个元素的值
        }
        //假设：int[] arr = {12,56,89,8}
        int max = arr[0];
        for(int i=1;i<arr.length;i++){
            if(arr[i]>max){
                max = arr[i];
            }
        }
        System.out.println(max);







        arr = Arrays.copyOf(arr,arr.length+1);   //扩容
        arr[arr.length-1] = max;  //将max赋值给arr的最后一个元素
        for(int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }
    }
}
